cmake_minimum_required(VERSION 3.0.2)

set( PROJECT_NAME UDP_TEST )
project(${PROJECT_NAME})



set(CMAKE_BUILD_TYPE "Debug") #Release

set(CMAKE_CXX_FLAGS "-std=c++11 -std=gnu++11")
#set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g"



#添加头文件目录
include_directories(
    include
    . 
    )
#添加连接库路径
list( APPEND PROJECK_LINKS_LIBS
    pthread
    ) 

IF (WIN32)  
    # Set Compiler，指定编译为32位程序
    SET(CMAKE_C_FLAGS "-m64")
    SET(CMAKE_CXX_FLAGS "-m64")
    
    MESSAGE(STATUS "Now is windows")  
    list( APPEND PROJECK_LINKS_LIBS
    ws2_32) 
ELSEIF (APPLE)  
    MESSAGE(STATUS "Now is Apple systens.")  
ELSEIF (UNIX)  
    MESSAGE(STATUS "Now is UNIX-like OS's. Including aPPLE os x  and CygWin") 
ENDIF () 

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
# 指定输出路径
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
# 添加 -fPIC 选项
# set_target_properties(udp_server PROPERTIES POSITION_INDEPENDENT_CODE ON)


set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")

add_library(udp_server SHARED # STATIC # SHARED  #动态库 
    thread/thread_base.cpp
    udp/udp_server.cpp
)

target_link_libraries(udp_server ${PROJECK_LINKS_LIBS})


add_executable(udp_client2
udp_test/udp_client2.cpp
)
target_link_libraries(udp_client2    udp_server)


add_executable(tcp_service
tcp_test/service.cpp
)
target_link_libraries(tcp_service ${PROJECK_LINKS_LIBS})


add_executable(tcp_client
tcp_test/client.cpp
)
target_link_libraries(tcp_client ${PROJECK_LINKS_LIBS})


add_executable( multicast
    udp_test/udp_multicast.cpp
    )
target_link_libraries(multicast  udp_server)


add_executable( testUdpCan
    udp_test/testUdpCan.cpp
    canbus/rm_udp_canbus.cpp
    )
target_link_libraries(testUdpCan  udp_server)


add_executable( udp_recv
    udp_test/udp_recv.cpp
    )
target_link_libraries(udp_recv  udp_server)


IF (WIN32)  
add_executable( serial
serial_win/Serial.cpp
SerialTest.cpp
)
ELSE()
add_executable( serial
serial/Serial.cpp
SerialTest.cpp
)
ENDIF()

